package com.xx.happychatboot.serve.user.domain.entity;

import java.io.Serializable;
import java.util.Date;

import io.mybatis.provider.Entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Id;

/**
 * <p>
 *  用户表
 * </p>
 *
 * @author xiaoXuan
 * @since 2024-12-10
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Entity.Table("sys_user")
public class SysUser implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @Entity.Column(value = "user_id", id = true, remark = "主键", updatable = false, insertable = false)
    @Id
    private Long userId;

    /**
     * 用户名
     */
    @Entity.Column("user_name")
    private String username;

    /**
     * 密码
     */
    @Entity.Column("password")
    private String password;

    /**
     * 是否启用
     */
    @Entity.Column("enabled")
    private Boolean enabled;

    /**
     * 用户帐户是否被锁定1未锁定0锁定
     */
    @Entity.Column("accountNonExpired")
    private Boolean accountNonExpired;

    /**
     * 帐户是否过期1未过期0过期
     */
    @Entity.Column("accountNonLocked")
    private Boolean accountNonLocked;

    /**
     * 凭据是否有效1有效0无效
     */
    @Entity.Column("credentialsNonExpired")
    private Boolean credentialsNonExpired;

    /**
     * 创建时间
     */
    @Entity.Column("create_time")
    private Date createTime;

    /**
     * 修改时间
     */
    @Entity.Column("update_time")
    private Date updateTime;

    public static SysUser newUser(String userName, String password) {
        SysUser user = new SysUser();
        user.setUsername(userName);
        user.setPassword(password);
        user.setEnabled(true);
        user.setAccountNonExpired(true);
        user.setCredentialsNonExpired(true);
        user.setAccountNonLocked(true);
        user.setCreateTime(new Date());
        user.setUpdateTime(new Date());
        return user;
    }
}
